#ifndef PLAYERHELPER_H
#define PLAYERHELPER_H

#include <QObject>
#include <QMediaPlayer>
#include <QMediaPlaylist>

class PlayerHelper : public QObject {
    Q_OBJECT
public:
    explicit PlayerHelper(QObject *parent = nullptr);
    ~PlayerHelper();

    // 播放控制
    void play();
    void pause();
    void stop();
    void setMedia(const QUrl& url);
    void setVolume(int volume);
    void setPosition(qint64 position);
    QMediaPlayer::State state() const;
    qint64 duration() const;

signals:
    // 播放进度变化
    void positionChanged(qint64 position);

    // 播放时长变化
    void durationChanged(qint64 duration);

private:
    QMediaPlayer* player;
    QMediaPlaylist* playlist;
};

#endif // PLAYERHELPER_H
